package com.datasecops.scannerservices.util;

import com.datasecops.scannerservices.db.*;
import com.datasecops.scannerservices.enumerate.DBType;

/**
 * DB工厂模式
 *
 * @author: SunLingzhi
 * @time: 2022/8/12 16:41
 */
public class DBFactory {

    public static DBHelper getConnectDataSource(DBType type, String ip, int port, String user, String password,String Instance){
        switch (type) {
            case MYSQL:
            case MARIADB :
            case TIDB:
            case OCEANBASE:
            case HOTDB:
            case RDS_MYSQL:
            case RDS_MARIADB:
                return Mysql.getInstance(ip,port,user,password,Instance);
            case ORACLE:
                return Oracle.getInstance(ip,port,user,password,Instance);
            case SQLSERVER:
            case RDS_SQLSERVER:
                return SQLServer.getInstance(ip,port,user,password,Instance);
            case POSTGRESQL:
            case OPENGAUSS:
            case RDS_POSTGRESQL:
                return PostGreSQL.getInstance(ip,port,user,password,Instance);
            case DM:
                return DM.getInstance(ip,port,user,password,Instance);
            case HIVE:
                return Hive.getInstance(ip,port,user,password,Instance);
            case DB2:
                return DB2.getInstance(ip,port,user,password,Instance);
            case HBASE:
                return HBase.getInstance(ip,port,user,password,Instance);
            case OSCAR:
                return Oscar.getInstance(ip,port,user,password,Instance);
            default:
                return null;
        }

    }
}
